<?php echo $javascript->link('prototype.js');?>
<div class="temas index">
<h2><?php __('Temas');?></h2>
<p>
<?php
echo $paginator->counter(array(
'format' => __('Page %page% of %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%', true)
));
?></p>
<table cellpadding="0" cellspacing="0">
<tr>
	<th><?php echo $paginator->sort('Temas','Tema.nombre');?></th>
	<th><?php echo $paginator->sort('Creado Por','User.username');?></th>
	<th><?php echo $paginator->sort('fecha','Tema.fecha');?></th>
	<th><?php echo $paginator->sort('Cantidad de Topicos','Tema.cantidad') ;?></th>
	<?php if($grupo_id == 1){ //cuando es administrador sale las acciones edit y delete
		echo '<th class="actions"><?php __(\'Acciones\');?></th>';
	}?>
</tr>
<?php
$i = 0;
foreach ($temas as $tema):
	$class = null;
	if ($i++ % 2 == 0) {
		$class = ' class="altrow"';
	}
?>
	<tr<?php echo $class;?>>
		<td>
			<?php echo $html->link(__($tema['Tema']['nombre'], true), array('controller'=>'topicos','action'=>'index', $tema['Tema']['tema'])); ?>
			<br><?php echo $tema['Tema']['descripcion']; ?>
		</td>
		<td>
			<?php echo $tema['User']['username']; ?>
		</td>
		<td>
			<?php echo $tema['Tema']['fecha']; ?>
		</td>
		<td>
			<?php echo $tema['Tema']['cantidad'] ?>
		</td>
		<?php if($grupo_id == 1){ //que solo el administrador pueda modificar el topico o borrar
			echo '<td class="actions">';
				echo $html->link(__('Edit', true), array('action'=>'edit', $tema['Tema']['tema']));
				echo $html->link(__('Delete', true), array('action'=>'delete', $tema['Tema']['tema']), null, sprintf(__('Are you sure you want to delete # %s?', true), $tema['Tema']['tema']));
			echo '</td>';
		}?>
	</tr>
<?php endforeach; ?>
</table>
</div>
<div class="paging">
	<?php echo $paginator->prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'));?>
 | 	<?php echo $paginator->numbers();?>
	<?php echo $paginator->next(__('next', true).' >>', array(), null, array('class'=>'disabled'));?>
</div>
<div class="actions">
	<ul>
		<li><?php if($grupo_id <3 && $grupo_id!=null) //A partir del premium puede agregar temas
			echo $html->link(__('Nuevo Tema', true), array('action'=>'add')); ?></li>
	</ul>
</div>
